package com.woniu.p2p.controller;

import com.woniu.p2p.utils.EmailTool;
import com.woniu.p2p.utils.SMSTool;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sms")
public class SMSController {

	/**
	 * 发送手机验证码
	 * @param phone
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/sendSmsMsg/{phone}")
	@ResponseBody
	public String sendSmsMsg(@PathVariable("phone") String phone) throws Exception{
		String serverCode = SMSTool.getCode(phone);
		return serverCode;

	}

	/**
	 * 发送邮件
	 * @param email 收件人邮箱
	 * @return
	 */
	@RequestMapping("/sendEmail/{email}")
	public int sendEmail(@PathVariable("email") String email){
		return EmailTool.sendMail(email);
	}
}
